-- card: 8751 from stack: in.3 -- bmap block id: 14237 -- flags: 4000 -- background id: 8327 -- name: C Utilities -- part 5 (field) -- low flags: 01 -- high flags: 2007 -- rect: left=18 top=32 right=290 bottom=486 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: Documentation -- part 6 (button) -- low flags: 00 -- high flags: 8003 -- rect: left=299 top=298 right=320 bottom=438 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show C Source ----- HyperTalk script ----- on mouseUp get the visible of card field "source" set the visible of card field "source" to not it if it is false then set the name of me to "Hide C Source" else set the name of me to "Show C Source" end if end mouseUp -- part 7 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=18 top=31 right=291 bottom=486 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: Source -- part 11 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=18 top=32 right=285 bottom=481 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: got -- part contents for card part 5 ----- text ----- C Utilities 1.0d4 Roger Brown This is a collection of various C functions that are useful when creating XFCN's. They are written in THINK C™. New this version: • GetCardRect: gets the screen rectangle of the card window. Works with SuperCard. • ShowString: a debugging tool that lets you display a string in an answer dialog. • GetHCWord: gets a specified word from a HyperCard container. Previously released: • Number of HyperCard Items : int NumHCitems(char *source) Given a pointer to a source of HyperCard formatted items (comma delimited), return the number of items in it. • Get HyperCard Item : GetHCItem(char *inStr, int i, char *outStr) Given a HyperCard item list (comma delimited) in string inStr, get item i and return it as a string in outStr. • Number of HyperCard Lines : int NumHCLines(char *source) Given a pointer to a source of HyperCard formatted lines, such as a field, return the number of lines in it. • Get HyperCard Line : GetHCLine(int line, char *source, char *dest) Given a pointer to a source of lines (like a field), extract the requested line and return it in string dest. • Get HyperCard Expression : GetHCExpression(char *inStr, char *outStr) Given a HyperCard expression in inString, return its value in outStr. • String Contains : StrContains(char *target, char *test) Given string test, return TRUE if it contains the string target. • Get HyperCard Card WindowRectangle : GetCardRect(Rect *itsRect) Get the rectangle of HyperCard's card window. • Build a return result : ResultIs(XCmdBlockPtr paramPtr, char *theResult) Given a C formatted string, build a return result structure for the given parameter block. • GetHCRectangle: GetHCRectangle(str,aRect) Given a HyperCard rectangle specification in a string, return a QuickDraw rectangle. -- part contents for card part 7 ----- text ----- /* C Utilities 1.0a4.c */ /* version 1.0a4 9/14/89 */ /* Roger Brown, Dartmouth Courseware Development Group 7/7/88 */ /* HyperCard XCMD support library */ #include "HyperXCmd.h" /* change a string to all upper case */ ucase(s) char *s; { int i; char c; for (i=0;i 255 characters."); return; } if (c==(len-1)) { /* last word, no space */ count = count+1; break; } } } if (count < i) strcpy(outStr,"Error: word out of range"); /* no word there */ else { temp[j] = 0; /* make it a C string */ strcpy(outStr,temp); /* move to output string */ } return; } /* Get the number of HyperCard comma delimited items in string s. */ int NumHCItems(s) char *s; { int c; /* character pointer */ int len; /* length of string */ int count; /* count of items found */ int j; /* item byte counter */ count = j = 0; /* initialize */ len = strlen(s); /* will look this far */ for (c=0;c 255 characters."); return; } if (c==(len-1)) { /* last item, no comma */ count = count+1; break; } } } if (count < i) strcpy(outStr,"Error: item out of range"); /* no item there */ else { temp[j] = 0; /* make it a C string */ strcpy(outStr,temp); /* move to output string */ } return; } /* how many HyperCard lines in string source */ NumHCLines(source) char *source; { int c; /* character counter */ int l; /* line counter */ int len; len = strlen(source); l = 0; for (c=0;clen) { /* out of range */ strcpy(dest,"Error: Line out of range."); return; } } c = 0; /* at line, start transfer */ for (j=i;jreturnValue = resultHandle; } /* show a string in an answer dialog - for debugging */ ShowString(paramPtr,text) XCmdBlockPtr paramPtr; char *text; { Str255 temp; strcpy(temp,"answer \" "); strcat(temp,text); strcat(temp,"\""); CtoPstr((char *)temp); SendCardMessage(paramPtr,temp); } /* Change a HyperCard rectangle description into a QuickDraw rectangle */ GetHCRect(str,itsRect) Str255 str; Rect *itsRect; { Str255 it; long corner; GetHCItem(str,1,it); CtoPstr((char *)it); StringToNum(it,&corner); itsRect->left = (int)corner; GetHCItem(str,2,it); CtoPstr((char *)it); StringToNum(it,&corner); itsRect->top = (int)corner; GetHCItem(str,3,it); CtoPstr((char *)it); StringToNum(it,&corner); itsRect->right = (int)corner; GetHCItem(str,4,it); CtoPstr((char *)it); StringToNum(it,&corner); itsRect->bottom = (int)corner; }